import conf from '@/utils/conf'

function upload(params = {}) {
  return new Promise((resolve, reject) => {
    wx.uploadFile({
      url: `${conf.api}common/attach/upload`,
      filePath: params.file,
      header: {
        code: wx.getStorageSync('token')
      },
      name: 'file',
      formData:{
        'module_id': params.id,
        'module': params.name,
      },
      success: res => {
        resolve(res);
      },
      fail: err => {
        reject(err);
      },
    })
  })
}

export default upload;